#include <memory/spw_new.h>
#include <memory/spw_alloc.h>
#include <gtest/gtest.h>
int flag = 0;
struct Class{
    Class(double aa, const double& bb, int&& cc): a(aa), b(bb), c(cc){ flag = 111; }
    double a = 1.0;
    double b = 11.0;
    int c= 111;
    ~Class() { flag = 222; }
};

struct ConsTest: public testing::Test{
protected:
    virtual void SetUp() {
        std::cout << "-----------"<< __func__ << " setup-----------" << std::endl; 
    }
    virtual void TearDown() {
        std::cout << "-----------"<< __func__ << " teardown-----------" << std::endl; 
    }
public:
    void* test20 = operator new(20);
};

TEST_F(ConsTest, Test) {
    EXPECT_TRUE( flag == 0);
    spwstd::AllocInterface<Class>::s_construct(static_cast<Class*>(test20), 2.0, 22.0, 222);
    EXPECT_TRUE( flag == 111);
    EXPECT_TRUE(static_cast<Class*>(test20)->a == 2.0);
    EXPECT_TRUE(static_cast<Class*>(test20)->b == 22.0);
    EXPECT_TRUE(static_cast<Class*>(test20)->c == 222);
    spwstd::AllocInterface<Class>::s_destroy(static_cast<Class*>(test20));
    EXPECT_TRUE( flag == 222);
}
